package com.hyp.mapper;

import com.hyp.pojo.Product;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper {
    List<Product> list(String category,String description,Integer low,Integer high);

    //查询回显
    @Select("select * from product where productId = #{id}")
    Product getById(Integer id);

    //更新商品信息
    void update(Product product);

    //新增商品信息
    @Insert("insert into product (Name, Category, Price, Stock, Description, ImageURL, CreatedAt, UpdatedAt) " +
            "values (#{name},#{category},#{price},#{stock},#{description},#{imageURL},#{createdAt},#{updatedAt}) ")
    void addSave(Product product);

    //删除商品
    void delete(List<Integer> ids);

    @Select("select distinct Category from product;")
    List<String> getAllCategories();
    @Select("SELECT * FROM product WHERE category = #{category};")
    List<Product> catelist(String category);

}
